package api

import (
	"fmt"
	"github.com/gin-gonic/gin"
	nhttp "net/http"
	"wzgames/internal/api/v1/auth"
	"wzgames/internal/api/v1/bet"
	"wzgames/internal/api/v1/guest"
	"wzgames/internal/api/v1/wallet"
	"wzgames/internal/constant"
	"wzgames/pkg/server/http"
	"wzgames/pkg/server/http/types"
)

func initRouteGroups(group *gin.RouterGroup) {
	auth.RegisterRoute(group)
	wallet.RegisterRoute(group)
	guest.RegisterRoute(group)
	bet.RegisterRoute(group)
}

func InitRoute(g *gin.Engine) {
	rootGroup := g.Group("/")
	versionGroup := rootGroup.Group("wzgames")
	initRouteGroups(versionGroup)
	http.MethodMapper(versionGroup, types.GET)(healthFn())
}

var healthFn = func() (string, func(c *gin.Context)) {
	uri := fmt.Sprintf("/health")
	return uri, func(c *gin.Context) {
		c.String(nhttp.StatusOK, constant.OkStr)
		return
	}
}
